#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;
#define INFLL 0x7f
const int N = 1000005;
const int M = 1600005;
const long long MOD = 998244353;
int n, m, s, t;
bool visited[N];
long long dis[N], cnt[N];
vector<int> ver[N];

void spfa(){
	memset(dis, INFLL, sizeof dis);
	memset(visited, false, sizeof visited);
	queue<int> q;
	q.push(s);
	visited[s] = true;
	dis[s] = 0;
	cnt[s] = 1;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		visited[x] = false;
		for(int i=0;i<(int)ver[x].size();i++){
			int y = ver[x][i];
			if(dis[y] > dis[x] + 1){
				dis[y] = dis[x] + 1;
				cnt[y] = cnt[x] % MOD;
				if(!visited[y]){
					visited[y] = true;
					q.push(y);
				}
			}else if(dis[y] == dis[x] + 1){
				cnt[y] = (cnt[y] + cnt[x]) % MOD;
				if(!visited[y]){
					visited[y] = true;
					q.push(y);
				}
			}
		}
	}
}

int main(){
	int u, v;
	scanf("%d %d %d %d", &n, &m, &s, &t);
	for(int i=0;i<m;i++){
		scanf("%d %d", &u, &v);
		ver[u].push_back(v);
		ver[v].push_back(u);
	}
	spfa();
	printf("%lld\n", cnt[t]);
	return 0;
}
